<template>
  <t-card :bordered="false">
    <discuss-log-table
      ref="discussLogTable"
      @open-dialog="handleOpenDialog" 
     :create-params="{ 
        costList:[],
        reduceList:[],
        fileUrl:[],
        orderId: engineeringDetails.orderId
        }"
      :initial-params="{ 
        orderId: engineeringDetails.orderId,
        engineeringId: engineeringDetails.id
      }"
      />
      <discuss-log-dialog
        ref="disscussLogDialog"
        :order-id="engineeringDetails.orderId" 
        @request-success="handleDialogRequestSuccess"
      />
  </t-card>
</template>


<script setup lang="ts">
import dayjs from 'dayjs';
import { MessagePlugin, TableCol } from 'tdesign-vue-next';
import { inject, onMounted, Ref, ref, useTemplateRef } from 'vue';

import { discussLogListCRUD,  } from '@/api/project/details';
import { payContractZhengCRUD } from '@/api/finance/pay';

import DiscussLogTable from '@/pages/finance/pay/components/DiscussLogTable.vue';
import DiscussLogDialog from '@/pages/finance/pay/components/DiscussLogDialog.vue';
import Record from '@/pages/order/details/components/Record.vue';


// 施工详情
const engineeringDetails = inject<Ref<Record<string, any>>>('engineeringDetails');
// 洽商表格
const discussLogTable = useTemplateRef('discussLogTable');
// 恰商对话框ref
const disscussLogDialog = useTemplateRef('disscussLogDialog');



onMounted(() => {
  discussLogTable.value.initTable();
});

// 处理打开对话框
const handleOpenDialog = (mode: 'create' | 'read' | 'update', params: Record<string, any>) => {
    disscussLogDialog.value.open(mode, params);
  
};

// 处理对话框请求成功
const handleDialogRequestSuccess = (result: Record<string, any>) => {
  if (result.mode === 'create') discussLogTable.value.initTable();
  if (result.mode === 'update') discussLogTable.value.refreshTable();
};

</script>



